Channels
One-way broadcast channels: create, subscribe, publish posts.
Data models (app/models.py)
- Chat — for channels
chat_type='channel', withid,title,description,avatar,created_by,is_verified,created_at,subscribers_count. - ChannelMember —
id,channel_id,user_id,role(‘owner’ | ‘admin’ | ‘subscriber’),joined_at. - ChannelBind —
id,channel_id,group_id,created_at(links a discussion group). - Posts reuse the Message model with
chat_idpointing at the channel.
Endpoints (app/routes/spav2/channels.py)
All under V2 + '/api' → /api.v2/api/channels/...:
POST /api/api/channels/create— create a channel (title,description,avatar).GET /api/api/channels/info— channel metadata + subscriber count.GET /api/api/channels/subscribers— list subscribers.POST /api/api/channels/subscribe/POST /api/api/channels/unsubscribe— toggle membership.POST /api/api/channels/set-title/POST /api/api/channels/set-avatar— update metadata.POST /api/api/channels/verify— mark channel verified (admin only).- Publishing posts goes through
messages/sendwith the channelchat_id.
Frontend module (static/js/k/)
channels.js— channel browsing, subscribe buttons, post composition.
Notes
ChannelMember.roledistinguishesowner/adminfrom plainsubscriber.- Only
owner/admincan publish;messages/sendchecks the sender’s role in the channel. - Verification is restricted to
@admin_required.